# export CROSS_COMPILE = /home/hhquan/Projects/AI编译工具和框架/arc_toolchain_v3/opt/arc-fullhan-elf32/bin/arc-fullhan-elf32-

CXX = $(CROSS_COMPILE)g++
CC = $(CROSS_COMPILE)gcc
AR = $(CROSS_COMPILE)ar cqs

TOP_DIR = $(shell pwd)

TARGET_LIB = libaecm.a

# CCSRC += $(TOP_DIR)/aecm/aecm_core.cc
# CCSRC += $(TOP_DIR)/aecm/aecm_core_c.cc
# CCSRC += $(TOP_DIR)/aecm/delay_estimator.cc
# CCSRC += $(TOP_DIR)/aecm/delay_estimator_wrapper.cc
# CCSRC += $(TOP_DIR)/aecm/echo_control_mobile.cc
# CCSRC += $(TOP_DIR)/aecm/signal_processing_library.cc

CSRC += $(TOP_DIR)/aecm/aecm_core.c
CSRC += $(TOP_DIR)/aecm/aecm_core_c.c
CSRC += $(TOP_DIR)/aecm/delay_estimator.c
CSRC += $(TOP_DIR)/aecm/delay_estimator_wrapper.c
CSRC += $(TOP_DIR)/aecm/echo_control_mobile.c
CSRC += $(TOP_DIR)/aecm/signal_processing_library.c

CSRC += $(TOP_DIR)/aecm/complex_fft.c
CSRC += $(TOP_DIR)/aecm/real_fft.c
CSRC += $(TOP_DIR)/aecm/ring_buffer.c

# CSRC += $(TOP_DIR)/ns/fft4g.c
# CSRC += $(TOP_DIR)/ns/noise_suppression.c
# CSRC += $(TOP_DIR)/ns/ns_core.c

CSRC += $(TOP_DIR)/ns/noise_suppression_x.c
CSRC += $(TOP_DIR)/ns/copy_set_operations.c
CSRC += $(TOP_DIR)/ns/division_operations.c
CSRC += $(TOP_DIR)/ns/energy.c
CSRC += $(TOP_DIR)/ns/get_scaling_square.c
CSRC += $(TOP_DIR)/ns/nsx_core.c
CSRC += $(TOP_DIR)/ns/nsx_core_c.c

INC_DIR += -I$(TOP_DIR)
INC_DIR += -I$(TOP_DIR)/aecm
INC_DIR += -I$(TOP_DIR)/ns

CCOBJS := $(patsubst %.cc, %.o, $(CCSRC))
COBJS := $(patsubst %.c, %.o, $(CSRC))

LDFLAGS := 

CFLAGS := $(INC_DIR) 
CFLAGS += -Wall -O0

CXXFLAGS := $(INC_DIR) 
CXXFLAGS += -O3 -std=c++11 $(INC_DIR) 

$(TARGET_LIB):$(CCOBJS) $(COBJS)
	$(AR) -o $@ $^ $(LDFLAGS)

all:$(TARGET_LIB)
	@echo

$(COBJS):%.o:%.c
	@echo build $(notdir $@)
	@$(CC) $(CFLAGS) -c $< -o $@

$(CCOBJS):%.o:%.cc
	@echo build $(notdir $@)
	@$(CXX) $(CXXFLAGS) -c $< -o $@

$(CPPOBJS):%.o:%.cpp
	@echo build $(notdir $@)
	@$(CXX) $(CXXFLAGS)  -c $< -o $@

clean:
	rm -rf $(CCOBJS) $(COBJS) $(TARGET_LIB)
